<%--
  Created by IntelliJ IDEA.
  User: zhaoyingjie
  Date: 2021/10/11
  Time: 20:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<ul class="pagination">
    <li><a href="javascript:next_page(1)">首页</a></li>

    <c:if test="${info.pageNum<=1}">
        <li class="disabled"><a>&laquo;</a></li>
    </c:if>

    <c:if test="${info.pageNum>1}">
        <li><a href="javascript:next_page(${info.pageNum-1})">&laquo;</a></li>
    </c:if>


    <%--    处理标签的begin--%>
    <c:if test="${info.pageNum+2>=info.pages}">
        <c:set var="startPage" value="${info.pages-2}"></c:set>
        <c:set var="endPage" value="${info.pages}"></c:set>
    </c:if>

    <c:if test="${info.pageNum+2<info.pages}">
        <c:set var="startPage" value="${info.pageNum}"></c:set>

        <c:set var="endPage" value="${info.pageNum+2}"></c:set>
    </c:if>

    <%--    处理一下end--%>

    <%--    处理标签分页--%>
    <c:forEach begin="${startPage<=0?1:startPage}" end="${endPage}" var="v">
        <%--        处理一下当前页的背景颜色--%>
        <c:if test="${info.pageNum==v}">
            <li class="active"><a href="javascript:next_page(${v})">${v}</a></li>
        </c:if>

        <c:if test="${info.pageNum!=v}">
            <li><a href="javascript:next_page(${v})">${v}</a></li>
        </c:if>

    </c:forEach>

    <c:if test="${info.pageNum>=info.pages}">
        <li class="disabled text-danger"><a>&raquo;</a></li>
    </c:if>

    <c:if test="${info.pageNum<info.pages}">
        <li><a href="javascript:next_page(${info.pageNum+1})">&raquo;</a></li>
    </c:if>

    <li><a href="javascript:next_page(${info.pages})">尾页</a></li>
    <li><a href="#" class="text-danger">当前页${info.pageNum}/${info.pages}总页</a></li>
</ul>
